#include "ValueEncodedSolution.h"
#include "../SolutionFactory.h"

template <typename T>
ValueEncodedSolution<T>::ValueEncodedSolution()
{
    throw Unsupported_template_exception();
}

ValueEncodedSolution<int>::ValueEncodedSolution()
{
}

ValueEncodedSolution<int>::ValueEncodedSolution(vector<int> solution)
{
    chromosome = solution;
}

Solution *ValueEncodedSolution<int>::clone()
{
    return new ValueEncodedSolution(chromosome);
}

void ValueEncodedSolution<int>::mutate()
{
}

ostream &ValueEncodedSolution<int>::outputSolution(ostream &output)
{
    for (unsigned int i = 0; i < chromosome.size(); ++i)
        output << chromosome[i] << ' ';
        
    return output;
}

void ValueEncodedSolution<int>::fillWithRandomSolution(int length, int min, int max)
{
    for (int i = 0; i < length; ++i)
        chromosome.push_back(MyRandom::randInt(min, max));
}

template <typename T>
void ValueEncodedSolution<T>::push(T newValue)
{
    chromosome.push_back(newValue);
}

template <typename T>
T& ValueEncodedSolution<T>::operator [](int index)
{
    return chromosome[index];
}

template <typename T>
vector<T> ValueEncodedSolution<T>::getSolution()
{
    return chromosome;
}

template <typename T>
void ValueEncodedSolution<T>::setElement(int index, T value)
{
    chromosome[index] = value;
}

template <typename T>
T ValueEncodedSolution<T>::getElement(int index)
{
    return chromosome[index];
}

unsigned int ValueEncodedSolution<int>::getSize()
{
    return chromosome.size();
}

template <typename T>
SolutionType ValueEncodedSolution<T>::getSerializationIdentifyer() {
    return SF_VALUE_ENCODED_SOLUTION;
}

template class ValueEncodedSolution<int>;
